﻿using System;
using System.Diagnostics;
using System.Text;

namespace 字符串
{
    class Program
    {
        static void Main(string[] args)
        {
            //StringBuilder sb = new StringBuilder();
            //string str = null;
            ////创造了一个计时器，用来记录程序运行的时间
            //Stopwatch sw = new Stopwatch();
            //sw.Start();//开始计时
            //for (int i = 0; i < 100000; i++)
            //{
            //    sb.Append(i); 
            //}
            //sw.Stop();//计时结束
            //Console.WriteLine(sb.ToString());
            //Console.WriteLine(sw.Elapsed);

            //Console.WriteLine("请输入你喜欢的课程");
            //string a = Console.ReadLine();
            //Console.WriteLine("请输入你喜欢的课程");
            //string b = Console.ReadLine();
            //将字符串转换成大写
            //a = a.ToUpper();
            //b = b.ToUpper();
            //将字符串转换成小写
            //a = a.ToLower();
            //b = b.ToLower();

            //if (a.Equals(b,StringComparison.OrdinalIgnoreCase))
            //{
            //    Console.WriteLine("你们喜欢的课程相同");
            //}
            //else
            //{
            //    Console.WriteLine("你们喜欢的课程不相同");
            //}

            // string a = "a  b  +  -  *  /  ,";
            // //分割字符串调用Split
            // char[] b = { ' ','+','-','*','/',','};
            //string[] str= a.Split(b,StringSplitOptions.RemoveEmptyEntries);

            //string a = "2008-08-08";
            //string[] str = a.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            //Console.WriteLine("{0}年{1}月{2}日",str[0],str[1],str[2]);

            //将字符串中的关键字进行替换 Contains() Replace()
            //string s = "国家关键人物耀";
            //if (s.Contains("耀"))
            //{
            //    s = s.Replace("耀", "**");
            //}
            //Console.WriteLine(s);

            //Substring 截取字符串
            //string a = "今天天气好晴朗，处处好风光";
            //a = a.Substring(0,10);
            //Console.WriteLine(a);

            //string str = "今天天气好晴朗，处处好风光";
            //str.StartsWith判断字符串是否以--开头
            //str.EndsWith判断字符串是否以--结尾
            //if (str.StartsWith(""))
            //{
            //  Console.WriteLine("是的");
            //}
            //else
            //{
            //  Console.WriteLine("不是的");
            //}
            //IndexOf判断字符串第一次出现的位置。
            //string str = "今天天气好晴朗，处处好风光";
            //int aa = str.IndexOf("天");
            //Console.WriteLine(aa);

            //LastIndexOf 判断字符串中最后一次出现的位置
            //Substring 截取字符串
            //string path = @"c:\a\b\c\d\e\f\g\h\sa\adf\\f\df\df\fas\fasf\苍老师.wav";
            //int ina = path.LastIndexOf("\\");
            //path = path.Substring(ina + 1);
            //Console.WriteLine(path);

            //string str = "              hahaah              ";
            //清空所有空格
            //str = str.Trim();
            //清空前面的空格
            //str = str.TrimStart();
            //清空后面的空格
            //str = str.TrimEnd();
            //Console.Write(str);

            //string.IsNullOrEmpty  判断字符串是否为空
            //string str = "";
            //if (string.IsNullOrEmpty(str))
            //{
            //    Console.WriteLine("是的");
            //}
            //else
            //{
            //    Console.WriteLine("不是");
            //}

            //
            string[] names = { "张三", "李四", "王五", "赵六", "田七" };
            //张三|李四|王五|赵六|田七
            string str = string.Join("|", names);
            Console.WriteLine(str);
            Console.ReadKey();
        }
    }

}
